package mylib.dir;

/**
 * Created with IntelliJ IDEA.
 * User: 1
 * Date: 10.08.12
 * Time: 15:08
 * To change this template use File | Settings | File Templates.
 */
public class Point3d {
    public int x, y, z;

    public Point3d(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public Point3d add(Point3d other) {
        return new Point3d(x + other.x, y + other.y, z + other.z);
    }

    public Point3d subtract(Point3d other) {
        return new Point3d(x - other.x, y - other.y, z - other.z);
    }

    public double length() {
        return Math.sqrt(1.0 * x * x + 1.0 * y * y + 1.0 * z * z);
    }

    public long hypot() {
        return (long) x * x + (long) y * y + (long) z * z;
    }

    public double distance(Point3d other) {
        return Math.sqrt(Math.pow(x - other.x, 2) + Math.pow(y - other.y, 2) +
                Math.pow(z - other.z, 2));
    }

    public Point3d negate() {
        return new Point3d(-x, -y, -z);
    }

    @Override
    public String toString() {
        return "Point3d{" +
                "x=" + x +
                ", y=" + y +
                ", z=" + z +
                '}';
    }
}
